package metalink.admin;

import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
import java.sql.*;
import vo.*;
import vo.mixed.*;
import model.admin.*;
import myutil.*;

public class ParticipantsList extends ActionSupport {
	int event_id;
	String type;
    ArrayList<EventDetailsVo> event_participants_list=new ArrayList<EventDetailsVo>();
	public ArrayList<EventDetailsVo> getEvent_participants_list() {
		return event_participants_list;
	}

	public void setEvent_participants_list(
			ArrayList<EventDetailsVo> event_participants_list) {
		this.event_participants_list = event_participants_list;
	}

	public int getEvent_id() {
		return event_id;
	}

	public void setEvent_id(int event_id) {
		this.event_id = event_id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String execute() {
		try {
			Connect c=new Connect();
			if (type.equals("coming")) {
				ResultSet rs=c.getResult("select * from event_participation where event_id='"+event_id+"' and coming=1");
				while(rs.next()){
					EventDetailsVo single_object=new EventDetailsVo();
					single_object.setParticipant_id(rs.getString("participant_id"));
					event_participants_list.add(single_object);
				}
			}
			if (type.equals("notcoming")) {
				ResultSet rs=c.getResult("select * from event_participation where event_id='"+event_id+"' and notcoming=1");
				while(rs.next()){
					EventDetailsVo single_object=new EventDetailsVo();
					single_object.setParticipant_id(rs.getString("participant_id"));
					event_participants_list.add(single_object);
				}
			}
			if (type.equals("maybe")) {
				ResultSet rs=c.getResult("select * from event_participation where event_id='"+event_id+"' and maybe=1");
				while(rs.next()){
					EventDetailsVo single_object=new EventDetailsVo();
					single_object.setParticipant_id(rs.getString("participant_id"));
					event_participants_list.add(single_object);
				}
			}
			return SUCCESS;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return ERROR;
		}

	}

}
